<template>
<div>
  <div class="banner" @click="clickshow">
    <div class="banner-img">
      <img src="https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_710x360_0288385b.jpg" alt="">
    </div>
    <div class="banner-info">
      <div class="info-write">
        <p>长城五一三日免费游</p>
      </div>
      <div class="info-icon">
        <span class="iconfont">&#xe600;</span>
        <span>2</span>
      </div>
    </div>
    <router-link to="/">
    <div class="icon-back"><span class="iconfont">&#xe608;</span></div>
    </router-link>
  </div>
  <!-- 详情页header导航 -->
  <transition>
  <div class="header" v-show="headershow">
    <router-link to="/">
    <div class="iconfont">&#xe623;</div>
    </router-link>
    <p>详情</p>
  </div>
  </transition>
  <!-- 展示秃瓢组件 -->
  <banner-detail @clickshowbanner="clickshowbanner" :imglist="imglist" :show="show"></banner-detail>
  <!--  -->
</div>
</template>

<script>
import BannerDetail from '../../components/detail/banner-detail'
export default {
  name: 'DetailBanner',
  data () {
    return {
      swiperOptions: {
        loop: true
      },
      imglist: [
        'https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_710x360_0288385b.jpg',
        'https://imgs.qunarzz.com/sight/p0/1708/2b/2b3b94de99c0a425a3.img.jpg_710x360_0288385b.jpg'
      ],
      show: false,
      headershow: false
    }
  },
  methods: {
    clickshow () {
      this.show = true
    },
    clickshowbanner () {
      this.show = false
    },
    showinfo () {
      const scolltop = document.documentElement.scrollTop
      console.log(scolltop)

      if (scolltop > 56) {
        this.headershow = true
      } else {
        this.headershow = false
      }
    }
  },
  mounted () {
    window.addEventListener('scroll', this.showinfo)
  },
  beforeDestroy () {
    window.removeEventListener('scroll', this.showinfo)
  },
  components: {
    BannerDetail
  }
}
</script>

<style lang="scss" scoped>
.v-enter-active,.v-leave-active{
  transition: all 1s;
}
.v-enter,.v-leave-to{
  opacity: 0;
}
.banner {
  position: relative;
  overflow: hidden;
  height: 0;
  width: 100%;
  padding-bottom: 50%;
  .icon-back{
    position: absolute;
    top: 0.1rem;
    left: 0.1rem;
    font-size: .5rem;
    background: rgba(172, 169, 169, 0.5);
    border-radius: .16rem;
    color: rgb(187, 183, 183);
  }
  .banner-img {
    img {
      width: 100%;
      height: 100%;
    }
  }
  .banner-info {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    line-height: 0.5rem;
    display: flex;
    justify-content: space-between;
    background-image: linear-gradient(
      top,
      rgba(54, 9, 179, 0),
      rgba(40, 206, 95, 0.8)
    );
    .info-write {
      font-weight: 700;
      color: white;
      margin-left: 0.3rem;
      flex: 1;
    }
    .info-icon {
      color: white;
      margin-right: 0.5rem;
      span {
        margin-left: 0.1rem;
      }
    }
  }
}
.header{
     height: .86rem;
     line-height: .86rem;
     text-align: center;
     color: white;
     background: #00bcd4;
     position: relative;
     font-size: .32rem;
     position: fixed;
     top: 0;
     left: 0;
     right: 0;
     .iconfont{
         position: absolute;
         top: 0;
         left: .0;
         font-size: .56rem;
         color: rgb(245, 239, 239);
     }
 }
</style>
